package me.dr0n3.skyRanks.Utils;

import java.util.HashMap;
import me.dr0n3.skyRanks.skyRanks;
import org.bukkit.entity.Player;

/**
 * @author dr0n3
 * @date 20.04.2012
 */
public class TimeHelper 
{    
    public static HashMap<Player, Long> hmLoginTime = new HashMap<>();
    
    public static String MsToTime(long lMs)
    {
        long time = lMs / 1000;  
        String seconds = Integer.toString((int)(time % 60));  	
        String minutes = Integer.toString((int)((time % 3600) / 60));  
	String hours = Integer.toString((int)(time / 3600));    
	
        if (seconds.length() < 2) 
        {  
		seconds = "0" + seconds;  
	}  
	if (minutes.length() < 2) 
        {  
		minutes = "0" + minutes;  
	}  
	if (hours.length() < 2) 
        {  
		hours = "0" + hours;  
	}
	return  hours + ":" + minutes + ":" + seconds;
    }
    
    public static void getLoginTimeOnEnabled(skyRanks plugin)
    {
        hmLoginTime.clear();
        
        for(Player p : plugin.getServer().getOnlinePlayers())
        {
            if(p.isOnline())
            {
                hmLoginTime.put(p, System.currentTimeMillis());
            }
        }
    }
}
